"use strict";

/**
 * Created by xuchao on 15/10/16.
 */

angular.module('manager', ['ui.router','app.controller'])
  .config(function ($stateProvider) {
    $stateProvider.state('init', {
      url: '/?openid&activityId&itemId',
      templateUrl: 'app/templates/init.html',
      controller:'InitCtrl'
    })
      .state('home', {
        url: '/h/:activityId/:openid',
        templateUrl: 'app/templates/home.html',
        controller:'HomeCtrl',
        resolve: {
          items: function(RestService, $stateParams) {
            return RestService.queryItems($stateParams.activityId, null, 1, 50).$promise;
          }
        }
      })
      .state('rank', {
        url: '/r/:activityId',
        templateUrl: 'app/templates/rank.html',
        controller:'RankCtrl',
        resolve: {
          rank: function(RestService, $stateParams) {
            return RestService.rank($stateParams.activityId, 1, 50).$promise;
          }
        }
      })
      .state('detail', {
        url: '/d/:id/:activityId/:openid',
        templateUrl:'app/templates/detail.html',
        controller: 'DetailCtrl',
        resolve: {
          detail: function (RestService, $stateParams) {
            return RestService.getItem($stateParams.id).$promise;
          }
        }
      })
  });
